package lock;

import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.*;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Description: 作用描述
 * @Author: hmm
 * @CreateDate: 2019/8/10$ 9:26$
 * @UpdateUser: hmm
 * @UpdateDate: 2019/8/10$ 9:26$
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public class LockDemo {
    public static void main(String[] args) {

        ReentrantLock lock = new ReentrantLock();

        ThreadPoolExecutor pool = new ThreadPoolExecutor(8, 10, 30, TimeUnit.SECONDS, new LinkedBlockingDeque<>(), Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());
        for (int i = 0; i < 10; i++) {
            pool.submit(() -> {
                try {
                    lock.lock();
                    Thread.interrupted();
                    System.out.println(Thread.currentThread().getName());
                } finally {
                    lock.unlock();
                }
            });
        }
    }
}
